package com.why.simpleboot.core.common.utils;

import com.why.simpleboot.core.annotation.ioc.Component;

/**
 * @program: why-simpleboot-framework
 * @description:
 * @author: @why
 * @create: 2021-05-23 23:05
 **/
public class SimpleIocUtils {
    /**
     * 获取bean的名字
     *
     * @param clazz
     * @return
     */
    public static String getBeanName(Class<?> clazz) {
        String name;
        if (clazz.isAnnotationPresent(Component.class)) {
            Component component = clazz.getAnnotation(Component.class);
            name = component.name();
            name = "".equals(name) ? clazz.getName() : name;
        }else{
            name=clazz.getName();
        }

        return name;
    }
}
